using DocumentFormat.OpenXml.Bibliography;
using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 生产设备
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("Equipment", "生产设备")]
public class Equipment
{
    /// <summary>
    /// Id
    /// </summary>
    [SugarColumn(ColumnName = "Id", ColumnDescription = "Id", IsPrimaryKey = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 公司代码
    /// </summary>
    [SugarColumn(ColumnName = "CompanyCode", ColumnDescription = "公司代码")]
    public Guid CompanyCode { get; set; }

    /// <summary>
    /// 设备编号
    /// </summary>
    [SugarColumn(ColumnName = "EquipmentNo", ColumnDescription = "设备编号", Length = 20)]
    [Required, MaxLength(20)]
    public string EquipmentNo { get; set; } = string.Empty;

    /// <summary>
    /// 设备名称
    /// </summary>
    [SugarColumn(ColumnName = "Name", ColumnDescription = "设备名称", Length = 50)]
    [Required, MaxLength(50)]
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// 设备名称2
    /// </summary>
    [SugarColumn(ColumnName = "AlternativeName", ColumnDescription = "设备名称2", Length = 50)]
    [MaxLength(50)]
    public string? AlternativeName { get; set; }

    /// <summary>
    /// 管理编号
    /// </summary>
    [SugarColumn(ColumnName = "ManageNo", ColumnDescription = "管理编号", Length = 30)]
    [MaxLength(30)]
    public string? ManageNo { get; set; }

    /// <summary>
    /// TPM设备分组
    /// </summary>
    [SugarColumn(ColumnName = "TPMDeviceGroupId", ColumnDescription = "TPM设备分组")]
    public Guid TPMDeviceGroupId { get; set; }

    /// <summary>
    /// 设备类型
    /// </summary>
    [SugarColumn(ColumnName = "TPMCategoryId", ColumnDescription = "设备类型")]
    public Guid TPMCategoryId { get; set; }

    /// <summary>
    /// 使用部门
    /// </summary>
    [SugarColumn(ColumnName = "UserDepartmentID", ColumnDescription = "使用部门", Length = 50)]
    [MaxLength(50)]
    public string? UserDepartmentID { get; set; }

    /// <summary>
    /// 固定资产标识
    /// </summary>
    [SugarColumn(ColumnName = "IsAsset", ColumnDescription = "固定资产标识")]
    public bool IsAsset { get; set; }

    /// <summary>
    /// 资产编号
    /// </summary>
    [SugarColumn(ColumnName = "AssetId", ColumnDescription = "资产编号")]
    public Guid? AssetId { get; set; }

    /// <summary>
    /// 设备状态
    /// </summary>
    [SugarColumn(ColumnName = "EquipmentStatus", ColumnDescription = "设备状态")]
    public Guid EquipmentStatus { get; set; }

    /// <summary>
    /// 品牌
    /// </summary>
    [SugarColumn(ColumnName = "Brand", ColumnDescription = "品牌")]
    public Guid? Brand { get; set; }

    /// <summary>
    /// 型号
    /// </summary>
    [SugarColumn(ColumnName = "Model", ColumnDescription = "型号", Length = 50)]
    [MaxLength(50)]
    public string? Model { get; set; }

    /// <summary>
    /// 供应商
    /// </summary>
    [SugarColumn(ColumnName = "Supplier", ColumnDescription = "供应商")]
    public Guid? Supplier { get; set; }

    /// <summary>
    /// 入厂日期
    /// </summary>
    [SugarColumn(ColumnName = "EnterDate", ColumnDescription = "入厂日期")]
    public DateTime? EnterDate { get; set; }

    /// <summary>
    /// 购入日期
    /// </summary>
    [SugarColumn(ColumnName = "PurchaseDate", ColumnDescription = "购入日期")]
    public DateTime? PurchaseDate { get; set; }

    /// <summary>
    /// 管理员
    /// </summary>
    [SugarColumn(ColumnName = "Manager", ColumnDescription = "管理员", Length = 20)]
    [MaxLength(20)]
    public string? Manager { get; set; }

    /// <summary>
    /// 使用人
    /// </summary>
    [SugarColumn(ColumnName = "UserNo", ColumnDescription = "使用人", Length = 20)]
    [MaxLength(20)]
    public string? UserNo { get; set; }

    /// <summary>
    /// 点检人
    /// </summary>
    [SugarColumn(ColumnName = "Checkuper", ColumnDescription = "点检人", Length = 20)]
    [MaxLength(20)]
    public string? Checkuper { get; set; }

    /// <summary>
    /// 保养人
    /// </summary>
    [SugarColumn(ColumnName = "Upkeepr", ColumnDescription = "保养人", Length = 20)]
    [MaxLength(20)]
    public string? Upkeepr { get; set; }

    /// <summary>
    /// 所在地
    /// </summary>
    [SugarColumn(ColumnName = "Position", ColumnDescription = "所在地")]
    public Guid Position { get; set; }

    /// <summary>
    /// 互联IP
    /// </summary>
    [SugarColumn(ColumnName = "IP", ColumnDescription = "互联IP", Length = 20)]
    [MaxLength(20)]
    public string? IP { get; set; }

    /// <summary>
    /// 端口
    /// </summary>
    [SugarColumn(ColumnName = "Port", ColumnDescription = "端口")]
    public int? Port { get; set; }

    /// <summary>
    /// 采集间隔
    /// </summary>
    [SugarColumn(ColumnName = "Interval", ColumnDescription = "采集间隔")]
    public int? Interval { get; set; }

    /// <summary>
    /// 注册地址
    /// </summary>
    [SugarColumn(ColumnName = "RegisterAdder", ColumnDescription = "注册地址", Length = 20)]
    [MaxLength(20)]
    public string? RegisterAdder { get; set; }

    /// <summary>
    /// PLC端口
    /// </summary>
    [SugarColumn(ColumnName = "PLCPort", ColumnDescription = "PLC端口")]
    public int? PLCPort { get; set; }

    /// <summary>
    /// PLC类型
    /// </summary>
    [SugarColumn(ColumnName = "PLCType", ColumnDescription = "PLC类型", Length = 30)]
    [MaxLength(30)]
    public string? PLCType { get; set; }

    /// <summary>
    /// 图片
    /// </summary>
    [SugarColumn(ColumnName = "Picture", ColumnDescription = "图片")]
    public byte[] Picture { get; set; }

    /// <summary>
    /// 关键字
    /// </summary>
    [SugarColumn(ColumnName = "Remark", ColumnDescription = "关键字", Length = 50)]
    [MaxLength(50)]
    public string? Remark { get; set; }

    /// <summary>
    /// 创建用户
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "创建用户", Length = 20)]
    [Required, MaxLength(20)]
    public string CreateUser { get; set; } = string.Empty;

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 更新用户
    /// </summary>
    [SugarColumn(ColumnName = "UpdateUser", ColumnDescription = "更新用户", Length = 20)]
    [MaxLength(20)]
    public string? UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTime", ColumnDescription = "更新时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// </summary>
    [SugarColumn(ColumnName = "IsDelete", ColumnDescription = "")]
    public bool IsDelete { get; set; }

    /// <summary>
    /// CompanyCode (公司代码) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CompanyCode), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_CompanyCode { get; set; }

    /// <summary>
    /// TPMDeviceGroupId (TPM设备分组) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(TPMDeviceGroupId), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_TPMDeviceGroupId { get; set; }

    /// <summary>
    /// TPMCategoryId (设备类型) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(TPMCategoryId), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_TPMCategoryId { get; set; }

    /// <summary>
    /// UserDepartmentID (使用部门) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UserDepartmentID), nameof(Department.DepartmentId))]//多对一
    public Department department_UserDepartmentID { get; set; }

    /// <summary>
    /// AssetId (资产编号) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(AssetId), nameof(Asset.Id))]//多对一
    public Asset asset_AssetId { get; set; }

    /// <summary>
    /// EquipmentStatus (设备状态) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(EquipmentStatus), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_EquipmentStatus { get; set; }

    /// <summary>
    /// Brand (品牌) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Brand), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Brand { get; set; }

    /// <summary>
    /// Supplier (供应商) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Supplier), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Supplier { get; set; }

    /// <summary>
    /// Manager (管理员) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Manager), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_Manager { get; set; }

    /// <summary>
    /// UserNo (使用人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UserNo), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UserNo { get; set; }

    /// <summary>
    /// Checkuper (点检人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Checkuper), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_Checkuper { get; set; }

    /// <summary>
    /// Upkeepr (保养人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Upkeepr), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_Upkeepr { get; set; }

    /// <summary>
    /// Position (所在地) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(Position), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_Position { get; set; }

    ///// <summary>
    ///// PLCType (PLC类型) 对应的外键实体
    ///// </summary>
    //[Navigate(NavigateType.ManyToOne, nameof(PLCType), nameof(PlcTypeBase.PLCType))]//多对一
    //public PlcTypeBase plcTypeBase_PLCType { get; set; }

    /// <summary>
    /// CreateUser (创建用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }

    /// <summary>
    /// UpdateUser (更新用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UpdateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UpdateUser { get; set; }

    /// <summary>
    /// 子表：点检设备
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(Checkup.EquipmentId))]//一对多
    public List<Checkup> Checkups { get; set; }

    ///// <summary>
    ///// 子表：设备变动历史
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(EquipmentChange.EquipmentId))]//一对多
    //public List<EquipmentChange> EquipmentChanges { get; set; }

    ///// <summary>
    ///// 子表：设备参数
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(EquipmentParas.EquipmentId))]//一对多
    //public List<EquipmentParas> EquipmentParases { get; set; }

    ///// <summary>
    ///// 子表：设备配件
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(EquipmentParts.EquipmentId))]//一对多
    //public List<EquipmentParts> EquipmentPartses { get; set; }

    ///// <summary>
    ///// 子表：设备寄存器信息
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(EquipmentPLC.EquipmentId))]//一对多
    //public List<EquipmentPLC> EquipmentPLCs { get; set; }

    ///// <summary>
    ///// 子表：设备维修信息
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(EquipmentRepair.EquipmentId))]//一对多
    //public List<EquipmentRepair> EquipmentRepairs { get; set; }

    ///// <summary>
    ///// 子表：设备SOP
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(EquipmentSop.EquipmentId))]//一对多
    //public List<EquipmentSop> EquipmentSops { get; set; }

    ///// <summary>
    ///// 子表：设备保养计划所属设备
    ///// </summary>
    //[Navigate(NavigateType.OneToMany, nameof(UpkeepPlanEquipment.EquipmentId))]//一对多
    //public List<UpkeepPlanEquipment> UpkeepPlanEquipments { get; set; }
}